//
//  BBDrawCell.swift
//  BBetter
//
//  Created by Gmc on 2020/3/14.
//  Copyright © 2020 Gmc. All rights reserved.
//

import UIKit

class BBDrawCell: UICollectionViewCell {
    
    open var model:BBDetailDescModel = BBDetailDescModel() {
        didSet {
            time.text = model.time
            today.text = "\(model.today)"
        }
    }
    open var progressH:CGFloat = 0 {
        didSet {
            progress.snp.updateConstraints { (make) in
                make.height.equalTo(progressH)
            }
        }
    }
    private var time:UILabel = UILabel()
    private var today:UILabel = UILabel()
    private var progress:UIView = UIView()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initSubviews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func initSubviews() {
        time.text = "0"
        today.text = "0"
        
        if (CheckDate.check(date: "04-04") || CheckDate.check(date: "12-13")) {
            today.textColor = UIColor.colorWithHexString(hexString: "272727")
            progress.backgroundColor = UIColor.colorWithHexString(hexString: "272727")
        } else {
            today.textColor = UIColor.colorWithHexString(hexString: "00BFFF")
            progress.backgroundColor = UIColor.colorWithHexString(hexString: "00BFFF")
        }

        time.font = UIFont.systemFont(ofSize: 12)
        today.font = UIFont.systemFont(ofSize: 12)
        contentView.addSubview(time)
        contentView.addSubview(today)
        contentView.addSubview(progress)
        time.snp.makeConstraints { (make) in
            make.bottom.equalTo(contentView)
            make.centerX.equalTo(contentView)
        }
        
        progress.snp.makeConstraints { (make) in
            make.bottom.equalTo(time.snp_top)
            make.width.equalTo(25)
            make.centerX.equalTo(contentView)
            make.height.equalTo(100)
        }
        
        today.snp.makeConstraints { (make) in
            make.centerX.equalTo(contentView)
            make.bottom.equalTo(progress.snp_top)
        }
        
    }
}
